Skip to content

Feature/dive detail section config#97

Merged
ericgriffin merged 17 commits into
mainfrom
feature/dive-detail-section-config
Mar 28, 2026
Merged

Feature/dive detail section config#97
ericgriffin merged 17 commits into
mainfrom
feature/dive-detail-section-config

Conversation

@ericgriffin

Copy link
Copy Markdown
Member

Summary

Add user-configurable ordering and visibility for dive detail page sections. Divers can reorder and hide/show sections via a new drag-and-drop settings page, with preferences persisted to the database.

Changes

  • Add DiveDetailSectionId enum and DiveDetailSectionConfig model with JSON serialization and forward-compatible section detection
  • Add diveDetailSections nullable TEXT column to diver_settings table (migration v56)
  • Wire section config through AppSettings, SettingsNotifier, and DiverSettingsRepository
  • Add DiveDetailSectionsPage with ReorderableListView, visibility toggle switches, and reset-to-default
  • Add navigation tile in Appearance settings (both mobile and desktop layouts) linking to the new page
  • Replace hardcoded section order on DiveDetailPage with config-driven rendering via a registry map
  • Add 69 tests covering model serialization, widget interactions, and settings provider behavior

Test Plan

  • flutter test passes
  • flutter analyze passes
  • Manual testing on: macOS

Screenshots

Screenshot 2026-03-28 at 1 38 26 AM Screenshot 2026-03-28 at 1 39 28 AM

Define the 17 configurable section IDs, their display metadata, and
JSON serialization for database storage. Includes ensureAllSections
for forward-compatible new-section detection.
Nullable TEXT column stores JSON section config. Null means use defaults.
No data backfill needed for existing divers.
New field with copyWith support and clear-to-defaults flag.
SettingsNotifier gets set and reset methods for the section config.
JSON serialization via DiveDetailSectionConfig.sectionsFromJson/toJson.
Stores null when config matches defaults to avoid unnecessary writes.
ReorderableListView with visibility toggle switches per section.
Reset to Default in overflow menu. Dimmed styling for hidden sections.
Navigation tile in Appearance links to /settings/dive-detail-sections.
New GoRoute wires the DiveDetailSectionsPage into the router.
Replace hardcoded section order with a registry map and loop over the
user's diveDetailSections config. Fixed sections (header, profile)
remain at the top. All data-driven auto-hide conditions preserved.
The previous code used List == (reference equality) to detect defaults
and write null. This always evaluates to false for loaded lists,
breaking the reset-to-defaults flow. Simplify by always writing JSON.
The settings page uses a separate _AppearanceSectionContent widget
for the master-detail layout on desktop. The new section was only
added to the mobile AppearancePage, not the desktop inline version.
Add 17 new tests (32 -> 49 total) covering:
- Model: fromJson missing visible field, fromJson unknown ID throws,
  copyWith no-args, round-trip serialization, ensureAllSections with
  empty list and custom visibility preservation
- Widget: toggle switch updates visibility, hidden section has reduced
  opacity, reset-to-default menu, initial switch state, app bar title,
  section descriptions
- AppSettings: copyWith preserves when unset, defaults match static
  const, clearDiveDetailSections takes precedence
Add 20 more tests (49 -> 69 total) covering:
- Model: fromJson explicit false, single-item round-trip, tryFromJson
  success/missing-id/non-string-id, sectionsFromJson with map-JSON/
  non-map-list-items/all-unknown-IDs/mixed-types, ensureAllSections
  preserves custom visibility, every displayName/description value,
  unique displayName constraint
- Widget: toggle back on restores opacity, multiple independent
  toggles, overflow menu present, subheading text, custom initial
  section order via provider override
- AppSettings: sequential copyWith independence, empty list, custom
  constructor
@ericgriffin
ericgriffin marked this pull request as ready for review March 28, 2026 05:54
Copilot AI review requested due to automatic review settings March 28, 2026 05:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds user-configurable ordering and visibility for Dive Detail page sections, persisting per-diver preferences to the database and wiring them through settings/state so the Dive Detail UI renders from configuration rather than a hardcoded order.

Changes:

  • Introduces DiveDetailSectionId / DiveDetailSectionConfig (JSON serialization + default/forward-compatible parsing).
  • Persists section configuration in diver_settings via a new nullable dive_detail_sections TEXT column and schema bump to v56.
  • Adds a new settings UI page for drag-and-drop reordering + visibility toggles, and updates Dive Detail rendering to be config-driven.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
lib/core/constants/dive_detail_sections.dart Defines section IDs, display metadata, config model, and JSON serialization/parsing helpers.
lib/core/database/database.dart Adds dive_detail_sections column and migrates schema version to 56.
lib/core/router/app_router.dart Registers the new settings route for configuring dive detail sections.
lib/features/settings/data/repositories/diver_settings_repository.dart Saves/loads section config JSON to/from diver_settings.
lib/features/settings/presentation/providers/settings_providers.dart Extends AppSettings + SettingsNotifier to hold and persist section config.
lib/features/settings/presentation/pages/dive_detail_sections_page.dart New UI for reordering and toggling section visibility + reset-to-default.
lib/features/settings/presentation/pages/appearance_page.dart Adds navigation entry to the new dive detail sections configuration page.
lib/features/settings/presentation/pages/settings_page.dart Adds navigation entry (desktop/mobile settings layout) to the new configuration page.
lib/features/dive_log/presentation/pages/dive_detail_page.dart Replaces hardcoded section order with config-driven rendering via a section builder registry.
test/core/constants/dive_detail_sections_test.dart Adds unit tests for section config defaults and serialization/deserialization behavior.
test/features/settings/presentation/pages/dive_detail_sections_page_test.dart Adds widget tests for reorder/toggle/reset behaviors and UI rendering.
test/features/settings/presentation/providers/settings_providers_test.dart Adds tests for AppSettings defaults and copyWith behavior for section config.
test/features/settings/presentation/pages/settings_page_test.dart Updates settings page test notifier mock for new settings APIs.
test/features/statistics/presentation/pages/records_page_test.dart Updates notifier mock for new settings APIs.

Comment thread lib/core/constants/dive_detail_sections.dart Outdated
Comment thread lib/features/settings/presentation/pages/appearance_page.dart Outdated
Comment thread lib/features/settings/presentation/pages/settings_page.dart Outdated
Comment thread lib/core/constants/dive_detail_sections.dart Outdated
Add localizedDisplayName() and localizedDescription() to DiveDetailSectionId
backed by ARB strings for all supported locales. Update settings and appearance pages to use localized section metadata. Add DiveDetailPage widget tests verifying section config visibility, ordering, and content rendering.
Add widget tests for dataSources, buddies, sightings, signatures, details, and all-sections-together rendering. Extract _buildTestWidget
extraOverrides parameter and _alwaysRenderOverrides helper for sections that require additional provider stubs.
@claude

claude Bot commented Mar 28, 2026

Copy link
Copy Markdown

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

… coverage

Add widget tests for AppearancePage verifying the Dive Details section header, tile content, and reorder icon. Extend section config tests with
dataSources, buddies, sightings, signatures, details, and all-sections rendering using extraOverrides for provider-dependent sections.
PR #95 (duration->bottomTime rename) claimed migration v56. Bump the
dive_detail_sections column addition to v57 and update schemaVersion.
- Bump migration from v56 to v57 (PR #95 claimed v56 for the
  duration->bottom_time column rename)
- Regenerate Drift code against updated schema
- Add missing setDiveDetailSections/resetDiveDetailSections stubs
  to MockSettingsNotifier
@ericgriffin
ericgriffin merged commit d546c0f into main Mar 28, 2026
19 checks passed
@ericgriffin
ericgriffin deleted the feature/dive-detail-section-config branch March 28, 2026 21:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants